filename='perhalfhourstock.txt';
fid = fopen(filename,'rt');
nLines = 0;
while (fgets(fid) ~= -1),
  nLines = nLines+1;
end
fclose(fid);
[month,day,year,hour,minute, open, high, low,close ] = textread(filename,'%d/%d/%d,%d:%d,%f,%f,%f,%f', nLines);
relevantdata=find(year>=2008);
month=month(relevantdata);
year=year(relevantdata);
day=day(relevantdata);
close=close(relevantdata);

date=[];
stocksval=[];
ii=1;
while ii<=length(close)
    date=[date;sprintf('%4d-%02d-%02d',year(ii),month(ii),day(ii))];
    stocksval=[stocksval;zeros(1,14)];
    daytemp=day(ii);
    pointcounter=1;
    while(day(ii)==daytemp)
        if pointcounter<=14        
            stocksval(size(stocksval,1),pointcounter)=close(ii);
        end;
        pointcounter=pointcounter+1;
        ii=ii+1;
        if ii>length(year)
            break;
        end
            
    end
end
stocksval=stocksval(:,1:13);
stockdate=date;
save('DJIAhalfhour.mat','stockdate','stocksval')
